/*
 * SongTableModel.java
 *
 * Created on June 20, 2005, 1:58 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */
package com.bff.slimserver.musicjukebox.ui.components.radio;

import com.bff.slimserver.musicjukebox.lib.JukeboxProperties;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.swing.table.*;
import org.bff.slimserver.musicobjects.SlimPodcastAudioDetails;

/**
 *
 * @author Bill Findeisen
 */
public class RadioTableModel extends AbstractTableModel {
 
    protected List<SlimPodcastAudioDetails> dataList;
    protected JukeboxProperties jp;
    public static final int TITLE = 0;
    public static final int LENGTH = 1;
    public static final int DATE = 2;
    public static final int ID = 3;

    public final static String[] columnNames = {
        "Id", "Title", "Length", "Date"
    };

    public RadioTableModel(Collection<SlimPodcastAudioDetails> podcasts) {
        jp = JukeboxProperties.getInstance();
        dataList = new ArrayList<SlimPodcastAudioDetails>(podcasts);
    }

    public int getRowCount() {
        return (dataList.size());
    }

    @Override
    public Object getValueAt(int row, int col) {
        SlimPodcastAudioDetails spad = dataList.get(row);
        switch (col) {
            case (TITLE):
                return spad.getTitle();
            case (LENGTH):
                return spad.getEnclosureLength();
            case (DATE):
                return spad.getPubDate();
            case ID:
                return spad.getId();
            default:
                return (null);
        }
    }

    @Override
    public Class getColumnClass(int column) {
            return super.getColumnClass(column);
    }

    public int getColumnCount() {
        return (columnNames.length);
    }

    public String getColumnName(int column) {
        return columnNames[column];
    }

    public int getIDColumnIndex() {
        return (ID);
    }

    public int getTitleColumnIndex() {
        return (TITLE);
    }

    public int getLengthColumnIndex() {
        return (LENGTH);
    }

    public int getDateColumnIndex() {
        return (DATE);
    }


    public int getSortColumn() {
        return getIDColumnIndex();
    }

    public SlimPodcastAudioDetails getPodcast(int row) {
        return (dataList.get(row));
    }
}
